package com.O2suanfa;

/**
 * 输入：cards = [1, 1, 2, 2, 3, 3, 4, 5, 5]
 * 输出：4
 * 解释：拿到数字 4 的同学是唯一一个没有配对的。
 *
 */
public class Test01 {

    public static int solution(int[] cards) {
        // Edit your code here
        for(int i = 0;i<cards.length;i++){
            int begin = cards[i];
            for(int j =0;j<cards.length;j++){
                if(cards[j] == begin && j != i) break;
                if(j == cards.length -1 && cards[j] != begin && j != i) {
                    System.out.println("i=="+i+"j=="+j+"begin=="+begin);
                    return begin;
                }
                if(i == cards.length-1 && j==i)  {
                    System.out.println("i=="+i+"j=="+j+"begin=="+begin);
                    return begin;
                }
            }

        }
        return 0;
    }

    public static void main(String[] args) {
        // Add your test cases here

        System.out.println(solution(new int[]{1, 1, 2, 2, 3, 3, 4, 5, 5}) == 4);
        System.out.println(solution(new int[]{0, 1, 0, 1, 2}) == 2);
    }


}
